#include <iostream>

using namespace std;

int main()
{
	int x = 1, y = 2, z = 3;
	int *p, *q, *r;
	p = &x;// p ---> dia chi cua x ma gia tri cua x = 1
	q = &y;// p ---> dia chi cua y ma gia tri cua y = 2
	r = &z;// p ---> dia chi cua z ma gia tri cua z = 3
	cout<<"value x: "<<x<<" value y: "<<y<<" value z: "<<z<<endl;// x = 1; y = 2; z = 3
	cout<<"value p: "<<p<<" value q: "<<q<<" value r: "<<r<<endl;// p = 0xxX; q = 0xxY; r = 0xxZ
	cout<<"value *p: "<<*p<<" value *q: "<<*q<<" value *r: "<<*r<<endl;// *p = 1; *q = 2; *r = 3
	cout<<"Swapping values"<<endl;
	r = q;// r = (q --> &Y) ==> r = 0xxY
	p = q;// p = (q --> &Y) ==> p = 0xxY
	q = r;// q = (r = 0xxY) ==> q = 0xxY
	cout<<"value x: "<<x<<" value y: "<<y<<" value z: "<<z<<endl;// x = 1; y = 2; z = 3
	cout<<"value p: "<<p<<" value q: "<<q<<" value r: "<<r<<endl;// p = 0xxY; q = 0xxY; r = 0xxY
	cout<<"value *p: "<<*p<<" value *q: "<<*q<<" value *r: "<<*r<<endl;// *p = 2; *q = 2; *r = 2
	system("pause");
}